package main

import (
	"encoding/json"
	"fmt"
)

func main() {
	var data = []any{
		111, 12.3, true, false, nil, "aaaa",
		[3]int{97, 98, 99},
		[]int{11, 22, 33},
		map[string]int{"abc": 123, "aa": 11},
		map[int]int{1: 11, 2: 22},
	}
	var targets [][]byte

	for i, v := range data {
		b, err := json.Marshal(v)
		if err != nil {
			continue
		}
		fmt.Printf("%d %T %[2]v ==> %T %[3]v, %s, %[4]q, %d\n", i, v, b, string(b), len(b))
		targets = append(targets, b)
	}
	t, _ := json.Marshal(data)
	// fmt.Println(t)
	fmt.Println(string(t))
	fmt.Println("~~~~~~~~~~~~~~~~~~")
	fmt.Println(targets)

	var v any
	err := json.Unmarshal(t, &v)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("%T %[1]v\n", v)
	fmt.Println("~~~~~~~~~~~~~~~~~~~~~")

	for i, v := range targets {
		var t any
		err := json.Unmarshal(v, &t)
		if err != nil {
			fmt.Println(i, err)
			continue
		}
		fmt.Printf("%d %T %[2]v ==> %[3]T %[3]v\n", i, v, t)
	}
}
